#include "frmprogressbar.h"
#include <QGridLayout>
#include <QDesktopWidget>
#include <QApplication>
#include <QPainter>
#include <QPalette>

CFrmProgressBar::CFrmProgressBar(QWidget *parent)
	: QWidget(parent)
{
	QGridLayout *mainLayout = new QGridLayout(this);

	mPro = new QProgressBar(this);

	mLab = new QLabel(this);

	mainLayout->addWidget(mPro,0,0);

	mainLayout->addWidget(mLab,1,0);




	this->setFixedSize(350,60);

	this->setWindowFlags(Qt::SubWindow);
	if (parent)
	{
		QRect rect = parent->geometry();

		this->move((rect.width() - this->width())/2,(rect.height() - this->height())/2);
	}


}

CFrmProgressBar::~CFrmProgressBar()
{

}

void CFrmProgressBar::onProjectFilePreLoaded()
{

}

void CFrmProgressBar::onProjectFileLoaded()
{
	
}

void CFrmProgressBar::onProjectLoadingProcessChanged( const EVString& tips,ev_uint8 percent )
{
	mLab->setText(tips.c_str());
	mPro->setValue(percent);
	mLab->repaint();
}

void CFrmProgressBar::paintEvent( QPaintEvent * ev )
{
	QPainter painter(this);
	painter.setPen(Qt::NoPen);
	painter.setBrush(QColor(palette().color(QPalette::Window)));
	painter.drawRect(rect());
}
